package com.ssy.lingxi.platform.manage.controller.mobile;

import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.platform.manage.api.model.dto.area.AreaDTO;
import com.ssy.lingxi.platform.manage.api.model.vo.area.LocationVO;
import com.ssy.lingxi.platform.manage.api.model.vo.area.ProvinceVO;
import com.ssy.lingxi.platform.manage.config.ServiceConfig;
import com.ssy.lingxi.platform.manage.model.response.RegionalInitialsResponse;
import com.ssy.lingxi.platform.manage.service.IAreaService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author lqa
 * @version 2.0.0
 * @menu 移动端定位
 * @date 2022/2/28
 */
@RestController
@RequestMapping("/manage/mobile")
public class AreaMobileController {

    @Resource
    private IAreaService areaService;

    /**
     * 根据经纬度获取城市信息
     *
     * @param location 请求数据 格式: 经度,纬度 -> 110.27321,21.60022
     * @return 操作结果
     */
    @GetMapping("/area/findByLocation")
    public Wrapper<LocationVO> findByLocation(@RequestParam("location") String location) {
        String code = ServiceConfig.PLATFORM_MANAGE_GAO_DE_API_CODE;//固定写死
        return areaService.findByLocation(code, location);

    }

    /**
     * 根据code查询下级区域，不传参数默认获取所有省份 (返回的参数带区域首字母)
     *
     * @param request 请求参数
     * @return 操作结果
     */
    @GetMapping("/area/findByPCode")
    public Wrapper<List<RegionalInitialsResponse>> findByPCode(AreaDTO request) {
        return areaService.findByPCode(request);
    }

    /**
     * 获取省市(返回的参数带市首字母)
     * @return 操作结果
     */
    @GetMapping("/area/findProCityFirstName")
    public Wrapper<List<ProvinceVO>> findProCityFirstName() {
        return areaService.findProCityFirstName();
    }

}
